/*
 * @Date: 2020-07-16 16:54:53
 * @LastEditTime: 2020-07-16 18:13:38
 * @Description: 自定义占位符
 * @FilePath: \vue\src\mock\extend.js
 */ 

import Mock from 'mockjs'
const Random = Mock.Random

/**
 * @param deviceName
 * @param address
 * @param rtspUrl
 * @param deviceId
 * @param fruit
 */

const mockExtend = Random.extend({
	// 自定义deviceName
	deviceName: function() {
		const arr = ["R19教室广角", "R19卫生间门口", "R19卫生间窗户", "R19卫生间中间", "R19宿舍云台", "R19宿舍广角", "R19活动区西", "R19活动区东","F1大门2层监控","测试"]
		return this.pick(arr);
	},
	// 自定义address
	address: function() {
		const arr = ["B1教学用房,1层,房间19", "B1教学用房,2层,房间29", "B1教学用房,1层,房间2", "B1教学用房,2层,房间6", "B1教学用房,3层,房间8", "R19宿舍广角",
			"B1教学用房,1层,房间6", "B1教学用房,2层,房间7", "B1教学用房,3层,房间12"
		]
		return this.pick(arr);
	},
	// 自定义rtsp_url
	rtspUrl: function() {
		return `rtsp://admin:admin123${this.ip()}:${Random.natural(1,9999)}/${this.protocol()}/main/av_stream`
	},
	// 自定义deviceId
	deviceId: function() {
		// B1左侧
		const arr = ["B1-JK1-" + Random.natural(1, 9)];
		// B1右侧
		const arr1 = ["B1-JK-G" + Random.natural(86, 227)];
		// 外景设备
		const arr2 = ["WJ7—" + Random.natural(1, 14)];
		const arr3 = ["XZ-" + Random.natural(1, 35)];
		let num = Random.natural(0, 20);
		// console.log(num);
		if (num >= 0 && num < 5) {
			return this.pick(arr)
		} else if (num >= 5 && num < 10) {
			return this.pick(arr1);
		} else if (num >= 10 && num < 15) {
			return this.pick(arr2);
		} else if (num >= 15 && num <= 20) {
			return this.pick(arr3);
		}
    },
    // 自定义fruit
    fruit: ()=> {
        return this.pick(["榴莲","菠萝蜜","荔枝","车厘子"])
    }
});

export default mockExtend